package com.sun.redis.config.config;

import com.sun.redis.config.constant.RedisLockConstants;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.integration.redis.util.RedisLockRegistry;

/**
 * <分布式redis锁配置类>
 *
 * @author 施瑞
 * @date 2021/6/3
 */
@Configuration
public class RedisLockConfig {

    /**
     * @param redisConnectionFactory 连接工厂
     * @return RedisLockRegistry redis锁管理
     */
    @Bean
    public RedisLockRegistry redisLockRegistry(RedisConnectionFactory redisConnectionFactory) {
        return new RedisLockRegistry(redisConnectionFactory, RedisLockConstants.Registry.REGISTRY_KEY,
                RedisLockConstants.Registry.REGISTRY_EXPIRE_TIME);
    }
}
